/// These tests are common between all libraries doing local evaluation of feature flags.
/// This ensures there are no mismatches between implementations.
use feature_flags::flag_matching::{FeatureFlagMatch, FeatureFlagMatcher};

use feature_flags::test_utils::create_flag_from_json;
use serde_json::json;

#[tokio::test]
async fn it_is_consistent_with_rollout_calculation_for_simple_flags() {
    let flags = create_flag_from_json(Some(
        json!([{
            "id": 1,
            "key": "simple-flag",
            "name": "Simple flag",
            "active": true,
            "deleted": false,
            "team_id": 1,
            "filters": {
                "groups": [
                    {
                        "properties": [],
                        "rollout_percentage": 45,
                    },
                ],
            },
        }])
        .to_string(),
    ));

    let results = vec![
        false, true, true, false, true, false, false, true, false, true, false, true, true, false,
        true, false, false, false, true, true, false, true, false, false, true, false, true, true,
        false, false, false, true, true, true, true, false, false, false, false, false, false,
        true, true, false, true, true, false, false, false, true, true, false, false, false, false,
        true, false, true, false, true, false, true, true, false, true, false, true, false, true,
        true, false, false, true, false, false, true, false, true, false, false, true, false,
        false, false, true, true, false, true, true, false, true, true, true, true, true, false,
        true, true, false, false, true, true, true, true, false, false, true, false, true, true,
        true, false, false, false, false, false, true, false, false, true, true, true, false,
        false, true, false, true, false, false, true, false, false, false, false, false, false,
        false, false, true, true, false, false, true, false, false, true, true, false, false, true,
        false, true, false, true, true, true, false, false, false, true, false, false, false,
        false, true, true, false, true, true, false, true, false, true, true, false, true, false,
        true, true, true, false, true, false, false, true, true, false, true, false, true, true,
        false, false, true, true, true, true, false, true, true, false, false, true, false, true,
        false, false, true, true, false, true, false, true, false, false, false, false, false,
        false, false, true, false, true, true, false, false, true, false, true, false, false,
        false, true, false, true, false, false, false, true, false, false, true, false, true, true,
        false, false, false, false, true, false, false, false, false, false, false, false, false,
        false, false, false, false, false, true, true, false, true, false, true, true, false, true,
        false, true, false, false, false, true, true, true, true, false, false, false, false,
        false, true, true, true, false, false, true, true, false, false, false, false, false, true,
        false, true, true, true, true, false, true, true, true, false, false, true, false, true,
        false, false, true, true, true, false, true, false, false, false, true, true, false, true,
        false, true, false, true, true, true, true, true, false, false, true, false, true, false,
        true, true, true, false, true, false, true, true, false, true, true, true, true, true,
        false, false, false, false, false, true, false, true, false, false, true, true, false,
        false, false, true, false, true, true, true, true, false, false, false, false, true, true,
        false, false, true, true, false, true, true, true, true, false, true, true, true, false,
        false, true, true, false, false, true, false, false, true, false, false, false, false,
        false, false, false, false, false, false, true, true, false, false, true, false, false,
        true, false, true, false, false, true, false, false, false, false, false, false, true,
        false, false, false, false, false, false, false, false, false, true, true, true, false,
        false, false, true, false, true, false, false, false, true, false, false, false, false,
        false, false, false, true, false, false, false, false, false, false, false, false, true,
        false, true, false, true, true, true, false, false, false, true, true, true, false, true,
        false, true, true, false, false, false, true, false, false, false, false, true, false,
        true, false, true, true, false, true, false, false, false, true, false, false, true, true,
        false, true, false, false, false, false, false, false, true, true, false, false, true,
        false, false, true, true, true, false, false, false, true, false, false, false, false,
        true, false, true, false, false, false, true, false, true, true, false, true, false, true,
        false, true, false, false, true, false, false, true, false, true, false, true, false, true,
        false, false, true, true, true, true, false, true, false, false, false, false, false, true,
        false, false, true, false, false, true, true, false, false, false, false, true, true, true,
        false, false, true, false, false, true, true, true, true, false, false, false, true, false,
        false, false, true, false, false, true, true, true, true, false, false, true, true, false,
        true, false, true, false, false, true, true, false, true, true, true, true, false, false,
        true, false, false, true, true, false, true, false, true, false, false, true, false, false,
        false, false, true, true, true, false, true, false, false, true, false, false, true, false,
        false, false, false, true, false, true, false, true, true, false, false, true, false, true,
        true, true, false, false, false, false, true, true, false, true, false, false, false, true,
        false, false, false, false, true, true, true, false, false, false, true, true, true, true,
        false, true, true, false, true, true, true, false, true, false, false, true, false, true,
        true, true, true, false, true, false, true, false, true, false, false, true, true, false,
        false, true, false, true, false, false, false, false, true, false, true, false, false,
        false, true, true, true, false, false, false, true, false, true, true, false, false, false,
        false, false, true, false, true, false, false, true, true, false, true, true, true, true,
        false, false, true, false, false, true, false, true, false, true, true, false, false,
        false, true, false, true, true, false, false, false, true, false, true, false, true, true,
        false, true, false, false, true, false, false, false, true, true, true, false, false,
        false, false, false, true, false, false, true, true, true, true, true, false, false, false,
        false, false, false, false, false, true, true, true, false, false, true, true, false, true,
        true, false, true, false, true, false, false, false, true, false, false, true, false,
        false, true, true, true, true, false, false, true, false, true, true, false, false, true,
        false, false, true, true, false, true, false, false, true, true, true, false, false, false,
        false, false, true, false, true, false, false, false, false, false, true, true, false,
        true, true, true, false, false, false, false, true, true, true, true, false, true, true,
        false, true, false, true, false, true, false, false, false, false, true, true, true, true,
        false, false, true, false, true, true, false, false, false, false, false, false, true,
        false, true, false, true, true, false, false, true, true, true, true, false, false, true,
        false, true, true, false, false, true, true, true, false, true, false, false, true, true,
        false, false, false, true, false, false, true, false, false, false, true, true, true, true,
        false, true, false, true, false, true, false, true, false, false, true, false, false, true,
        false, true, true,
    ];

    for i in 0..1000 {
        let distinct_id = format!("distinct_id_{}", i);

        let feature_flag_match = FeatureFlagMatcher::new(distinct_id, None, None)
            .get_match(&flags[0])
            .await
            .unwrap();

        if results[i] {
            assert_eq!(
                feature_flag_match,
                FeatureFlagMatch {
                    matches: true,
                    variant: None,
                }
            );
        } else {
            assert_eq!(
                feature_flag_match,
                FeatureFlagMatch {
                    matches: false,
                    variant: None,
                }
            );
        }
    }
}

#[tokio::test]
async fn it_is_consistent_with_rollout_calculation_for_multivariate_flags() {
    let flags = create_flag_from_json(Some(
        json!([{
            "id": 1,
            "key": "multivariate-flag",
            "name": "Multivariate flag",
            "active": true,
            "deleted": false,
            "team_id": 1,
            "filters": {
                "groups": [
                    {
                        "properties": [],
                        "rollout_percentage": 55,
                    },
                ],
                "multivariate": {
                    "variants": [
                        {
                            "key": "first-variant",
                            "name": "First Variant",
                            "rollout_percentage": 50,
                        },
                        {
                            "key": "second-variant",
                            "name": "Second Variant",
                            "rollout_percentage": 20,
                        },
                        {
                            "key": "third-variant",
                            "name": "Third Variant",
                            "rollout_percentage": 20,
                        },
                        {
                            "key": "fourth-variant",
                            "name": "Fourth Variant",
                            "rollout_percentage": 5,
                        },
                        {
                            "key": "fifth-variant",
                            "name": "Fifth Variant",
                            "rollout_percentage": 5,
                        },
                    ],
                },
            },
        }])
        .to_string(),
    ));

    let results = vec![
        Some("second-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        Some("fourth-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        Some("second-variant".to_string()),
        Some("third-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("fourth-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        None,
        None,
        None,
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("fifth-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        None,
        None,
        None,
        Some("third-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        Some("second-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        None,
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        None,
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        None,
        None,
        None,
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        None,
        None,
        None,
        None,
        Some("first-variant".to_string()),
        None,
        None,
        None,
        None,
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        None,
        None,
        Some("fifth-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("fifth-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        None,
        Some("fourth-variant".to_string()),
        None,
        None,
        None,
        None,
        Some("third-variant".to_string()),
        None,
        None,
        Some("third-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("second-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        None,
        None,
        Some("second-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("third-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        Some("fifth-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        Some("third-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("second-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("fifth-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("third-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        None,
        Some("third-variant".to_string()),
        None,
        None,
        Some("third-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        None,
        None,
        Some("fourth-variant".to_string()),
        Some("fourth-variant".to_string()),
        Some("third-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("fifth-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("fifth-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("second-variant".to_string()),
        Some("fifth-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        None,
        Some("third-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        Some("fifth-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        Some("fourth-variant".to_string()),
        None,
        None,
        Some("second-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        Some("fourth-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        None,
        None,
        Some("second-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("fifth-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("second-variant".to_string()),
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("fourth-variant".to_string()),
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        Some("fourth-variant".to_string()),
        Some("fifth-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("third-variant".to_string()),
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        Some("second-variant".to_string()),
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        None,
        None,
        None,
        Some("third-variant".to_string()),
        Some("fourth-variant".to_string()),
        Some("fourth-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        None,
        None,
        Some("fourth-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        Some("fourth-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        Some("third-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("second-variant".to_string()),
        Some("fourth-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        None,
        None,
        None,
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("third-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        Some("fifth-variant".to_string()),
        Some("fourth-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        Some("fourth-variant".to_string()),
        None,
        None,
        None,
        Some("fourth-variant".to_string()),
        None,
        None,
        Some("third-variant".to_string()),
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("third-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        None,
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        None,
        Some("fifth-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("third-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        None,
        Some("fourth-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("third-variant".to_string()),
        None,
        None,
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        Some("second-variant".to_string()),
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        Some("second-variant".to_string()),
        Some("third-variant".to_string()),
        Some("second-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        None,
        None,
        None,
        None,
        Some("first-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        None,
        Some("second-variant".to_string()),
        Some("third-variant".to_string()),
        Some("second-variant".to_string()),
        Some("fourth-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        None,
        None,
        None,
        None,
        None,
        Some("first-variant".to_string()),
        None,
        None,
        None,
        None,
        None,
        Some("first-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        None,
        None,
        None,
        None,
        Some("second-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        None,
        None,
        Some("second-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        None,
        None,
        Some("second-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        None,
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("fifth-variant".to_string()),
        None,
        None,
        None,
        Some("first-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        None,
        None,
        Some("second-variant".to_string()),
        None,
        None,
        None,
        None,
        None,
        Some("fourth-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        Some("fifth-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        Some("fifth-variant".to_string()),
        None,
        None,
        Some("third-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        None,
        None,
        None,
        None,
        Some("first-variant".to_string()),
        None,
        None,
        None,
        None,
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("fifth-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        Some("fourth-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        Some("fourth-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        Some("third-variant".to_string()),
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        Some("third-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        None,
        None,
        Some("second-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("fifth-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("fifth-variant".to_string()),
        None,
        None,
        None,
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("fourth-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("second-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        None,
        None,
        None,
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("second-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("fifth-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("fourth-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("fifth-variant".to_string()),
        None,
        None,
        None,
        Some("second-variant".to_string()),
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("second-variant".to_string()),
        None,
        None,
        Some("third-variant".to_string()),
        Some("second-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        None,
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        None,
        None,
        Some("first-variant".to_string()),
        Some("third-variant".to_string()),
        Some("second-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("third-variant".to_string()),
        Some("second-variant".to_string()),
        Some("third-variant".to_string()),
        None,
        None,
        Some("third-variant".to_string()),
        Some("first-variant".to_string()),
        None,
        Some("first-variant".to_string()),
    ];

    for i in 0..1000 {
        let distinct_id = format!("distinct_id_{}", i);

        let feature_flag_match = FeatureFlagMatcher::new(distinct_id, None, None)
            .get_match(&flags[0])
            .await
            .unwrap();

        if results[i].is_some() {
            assert_eq!(
                feature_flag_match,
                FeatureFlagMatch {
                    matches: true,
                    variant: results[i].clone(),
                }
            );
        } else {
            assert_eq!(
                feature_flag_match,
                FeatureFlagMatch {
                    matches: false,
                    variant: None,
                }
            );
        }
    }
}
